﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RPGMapa.Data;
using System.Drawing;

namespace RPGMapa.Data
{
    [Serializable()]
    public class Map
    {
        Bitmap layer;
        Vector2 nTiles;
        Vector2 sTiles;
        string name = "";
        string header = "";
        StringMatrix info;

        public Map()
        {
            this.name = "Bosque Sombrio";
            this.header = "aqui vão informações uteis e não tile based.";

            this.nTiles = new Vector2(20, 20);
            this.sTiles = new Vector2(15, 15);

            this.info = new StringMatrix(20, 20);
            this.layer = new Bitmap(nTiles.X * sTiles.X, nTiles.Y * sTiles.Y, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        }
        public Map(string name, Vector2 nT, Vector2 sT)
        {
            this.name = name;
            this.header = "aqui vão informações uteis ao parser do arquivo.";

            this.nTiles = nT;
            this.sTiles = sT;

            this.info = new StringMatrix(nT.X, nT.Y);
            this.layer = new Bitmap(nTiles.X * sTiles.X, nTiles.Y * sTiles.Y, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        }

        public void DrawTile(Bitmap tile, Vector2 pos)//int layerIndex
        {

            Graphics gL = Graphics.FromImage(layer);
            gL.DrawImage(tile, new Rectangle(pos.X * sTiles.X, pos.Y * sTiles.Y, sTiles.X, sTiles.Y));
        }
        public void WriteTile(Tile t, Vector2 pos)
        {
            info[pos.X, pos.Y] = t.Passable.ToString();
        }


        public Vector2 TileNumber
        {
            get { return nTiles; }
            set { nTiles = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public Vector2 TileSize
        {
            get { return sTiles; }
            set { sTiles = value; }
        }

        public Bitmap Layer
        {
            get { return layer; }
            set { layer = value; }
        }

        public string Header
        {
            get { return header; }
            set { header = value; }
        }

        public StringMatrix Info
        {
            get { return info; }
            set { info = value; }
        }
    }
}
